import * as types from './mutations_type'
import { saveUserInfo, saveUserPermissions } from '../common/js/cache'

const mutations = {
  [types.SET_IS_COLLAPSE](state) {
    state.isCollapse = !state.isCollapse
  },
  [types.SET_USER_INFO](state, userInfo) {
    state.userInfo = userInfo
    // 持久化 UserInfo
    saveUserInfo(userInfo)
  },
  [types.SET_USER_PERMISSIONS](state, userPermissions) {
    state.userPermissions = userPermissions
    // 持久化 UserPermissions
    saveUserPermissions(userPermissions)
  }
}

export default mutations
